﻿@{
    var branches = ViewData["branches"] as IEnumerable<string>;
    var tags = ViewData["tags"] as IEnumerable<string>;
    var isTag = tags.Contains(ViewData["referenceName"]);
}

@if (ViewData["branches"] != null)
{
    <nav class="branches">
        <ul>
            <li>
                <a href="#" class="@(isTag ? "tag" : "branch")">@ViewData["referenceName"]</a>
                @if (tags.Any() || branches.Any())
                {
                    <ul>
                        @{
                    var action = ViewContext.RouteData.Values["Action"].ToString() == "Blob" ? "Tree" : ViewContext.RouteData.Values["Action"].ToString();
                    foreach (var item in branches)
                    {
                        <li class="@(String.Equals(ViewData["referenceName"], item) ? "branch active" : "branch")">@Html.ActionLink(item as string, action, new { id = ViewContext.RouteData.Values["id"], encodedName = PathEncoder.Encode(item), encodedPath = String.Empty })</li>
                    }
                    foreach (var item in tags)
                    {
                        <li class="@(String.Equals(ViewData["referenceName"], item) ? "tag active" : "tag")">@Html.ActionLink(item as string, action, new { id = ViewContext.RouteData.Values["id"], encodedName = PathEncoder.Encode(item), encodedPath = String.Empty })</li>
                    }
                        }
                    </ul>
                }
            </li>
        </ul>
    </nav>
}


